import java.io.*;

public class Demo2 {
    public static void main(String[] args) {
        /*File file = new File("d:/code/J2025/J20250915-IO/test2.txt");
        System.out.println(file.exists());
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        System.out.println(file.exists());

        try (Writer writer = new FileWriter("d:/code/J2025/J20250915-IO/test2.txt",true)){
            writer.write("我是帅哥");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }*/

        try (Reader reader = new FileReader("d:/code/J2025/J20250915-IO/test2.txt")) {
            while (true) {
                char[] chars = new char[1024];
                int n = reader.read(chars);
                if (n == -1) {
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.println(chars[i]);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
